package com.enzoism.springboot.dive.common;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.List;

/**
 * 对象排序工具类
 */
public class CompareSortUtil {

    /**
     * 如果是ASC正序返回1，DESC倒叙返回-1
     * @param sortType
     * @return
     */
    public static int getSortIntValue(String sortType) {
        return StringUtils.equalsIgnoreCase(sortType, AppConstants.ORDER_TYPE_ASC) ? 1 : -1;
    }

    public static <T> void printDataList(List<T> dataList){
        if (CollectionUtils.isNotEmpty(dataList)){
            for (int i = 0; i < dataList.size(); i++) {
                System.out.println(dataList.get(i));
            }
        }
    }
}
